<template>
  <div class="app-container">
    <div v-if="user">
      <el-row :gutter="20">

        <el-col :span="6" :xs="24">
          <user-card :user="user" />
        </el-col>

        <el-col :span="18" :xs="24">
          <el-card>
            <el-tabs v-model="activeTab">
              <el-tab-pane label="时间线" name="timeline">
                <timeline />
              </el-tab-pane>
              <el-tab-pane label="账户信息" name="account">
                <account />
              </el-tab-pane>
            </el-tabs>
          </el-card>
        </el-col>

      </el-row>
    </div>
  </div>
</template>

<script>
import UserCard from './components/UserCard'
import Timeline from './components/Timeline'
import Account from './components/Account'
import { getAdminInfo } from '@/api/user'

export default {
  name: 'Profile',
  components: { UserCard, Timeline, Account },
  data() {
    return {
      // user: {},
      activeTab: 'timeline'
    }
  },
  computed: {
    user() {
      return this.$store.getters.user
    }
  },
  created() {
    this.getUser()
  },
  methods: {
    getUser() {
      if (!this.user) {
        getAdminInfo().then(res => {
          // this.user = res.object
          this.$store.commit('user/SET_USER', res.object)
        })
      }
    }
  }
}
</script>
